package com.zhaojk.audio.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.util.List;
import java.util.Map;

/**
 * Converts text into speech using a voice of your choice and returns audio.
 * <a href="https://api.elevenlabs.io/v1/text-to-speech/:voice_id">文档地址</a>
 *
 */
@Data
public class TTSRequest {
    private String text;
    @JsonProperty("model_id")
    private String modelId = "eleven_multilingual_v2";

    @JsonProperty("language_code")
    private String languageCode;

    @JsonProperty("voice_settings")
    private VoiceSettings voiceSettings;

    @JsonProperty("pronunciation_dictionary_locators")
    private List<Map> pronunciationDictionaryLocators;

    private int seed;

    @JsonProperty("previous_text")
    private String previousText;

    @JsonProperty("next_text")
    private String nextText;

    @JsonProperty("previous_request_ids")
    private List<String> previousRequestIds;

    @JsonProperty("next_request_ids")
    private List<String> nextRequestIds;

    /**
     * This parameter controls text normalization with three modes: ‘auto’, ‘on’, and ‘off’.
     * When set to ‘auto’, the system will automatically decide whether to apply text normalization (e.g., spelling out numbers).
     * With ‘on’, text normalization will always be applied, while with ‘off’, it will be skipped.
     * Cannot be turned on for ‘eleven_turbo_v2_5’ or ‘eleven_flash_v2_5’ models.
     * Allowed values: auto on off
     */
    @JsonProperty("apply_text_normalization")
    private String applyTextNormalization = "auto";

    @JsonProperty("apply_language_text_normalization")
    private boolean applyLanguageTextNormalization = false;

    public static class VoiceSettings{
        /**
         * 控制语音生成的稳定性与情感表达的平衡
         * 取值范围：0.0到1.0，默认值0.5
         * 需要情感丰富的语音，建议使用较低的stability值（0.3左右）
         * 清晰稳定的语音（如新闻播报、教学内容），建议使用较高的stability值（0.7左右）
         */
        private double stability;

        /**
         * 控制生成语音与选定声音样本的相似度
         * 取值范围：0.0到1.0，默认值0.7
         */
        @JsonProperty("similarity_boost")
        private double similarityBoost;

        /**
         * 控制语音的情感表达强度和风格
         * 取值范围：0.0到1.0，默认值为0
         * 值越高，语音的情感表达越丰富、越有戏剧性
         * 值越低，语音越中性、越接近平淡的朗读
         *
         */
        private double style;

        /**
         * 启用/禁用语音特征增强功能
         * 取值：布尔值(true/false)，默认值为true
         * 当设置为true时，系统会增强语音的清晰度和特定声音特征
         */
        @JsonProperty("use_speaker_boost")
        private boolean useSpeakerBoost;

        /**
         * 控制语音的语速
         * 调整方式：可通过输入具体数值，小于1.0降低语速，大于1.0加快语速
         * 默认值1.0
         */
        private double speed = 1.0;

        public double getStability() {
            return stability;
        }

        public void setStability(double stability) {
            this.stability = stability;
        }

        public double getSimilarityBoost() {
            return similarityBoost;
        }

        public void setSimilarityBoost(double similarityBoost) {
            this.similarityBoost = similarityBoost;
        }

        public double getStyle() {
            return style;
        }

        public void setStyle(double style) {
            this.style = style;
        }

        public boolean isUseSpeakerBoost() {
            return useSpeakerBoost;
        }

        public void setUseSpeakerBoost(boolean useSpeakerBoost) {
            this.useSpeakerBoost = useSpeakerBoost;
        }

        public double getSpeed() {
            return speed;
        }

        public void setSpeed(double speed) {
            this.speed = speed;
        }
    }
}
